#include <iostream>
#include <unordered_map>
#include <string>
#include <cmath>

bool is_prime(int n) {
    if (n < 2) {
        return false;
    }
    for (int i = 2; i <= std::sqrt(n); i++) {
        if (n % i == 0) {
            return false;
        }
    }
    return true;
}

int main() {
    std::unordered_map<std::string, int> words_to_numbers = {
        {"zero", 0}, {"one", 1}, {"two", 2}, {"three", 3}, {"four", 4},
        {"five", 5}, {"six", 6}, {"seven", 7}, {"eight", 8}, {"nine", 9}
    };

    std::string input;
    std::cout << "Введите три слова, разделенных пробелом: ";
    std::getline(std::cin, input);

    std::string word;
    int number = 0;
    for (char c : input) {
        if (c == ' ') {
            number = number * 10 + words_to_numbers[word];
            word.clear();
        } else {
            word += c;
        }
    }
    number = number * 10 + words_to_numbers[word];

    while (!is_prime(number)) {
        number++;
    }

    std::cout << "Ближайшее простое число: " << number << " \u2705" << std::endl;

    return 0;
}
